﻿
Option Strict On : Option Explicit On : Option Compare Binary : Option Infer On

Imports System
Imports System.Text

Namespace Utility

    Public Class StringHelper

        Public Shared Function Merge(ByVal values As String(), Optional ByVal seperator As String = ",") As String
            'if parameters are invalid, return nothing
            If values Is Nothing OrElse seperator Is Nothing Then Return Nothing

            Dim mergeResult As New StringBuilder
            For idx As Integer = 0 To values.Length - 1
                mergeResult.Append(values(idx))
                'if not the last element
                If idx <> values.Length - 1 Then _
                   mergeResult.Append(seperator)
            Next
            Return mergeResult.ToString()
        End Function

    End Class

End Namespace

